Skip to content

Conversation

@Kivooeo
Copy link
Contributor

@Kivooeo Kivooeo commented Nov 2, 2025

No description provided.

@Kivooeo Kivooeo mentioned this pull request Nov 2, 2025
@Kivooeo Kivooeo force-pushed the asd123 branch 2 times, most recently from bb3e51c to 786f15f Compare November 2, 2025 22:35
Comment on lines +14 to +17
```
[src/main.rs:17:5] capture!(2 + 3) = 5
[src/main.rs:18:5] transform!(2 + 3) = 6
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
[src/main.rs:17:5] capture!(2 + 3) = 5
[src/main.rs:18:5] transform!(2 + 3) = 6
```
```text
{{#include ../../code/examples/stderr/misc_7.stderr}}
```

Comment on lines 21 to 23
When `capture!(2 + 3)` is invoked, the `$e:expr` matcher captures `2 + 3` as a single expression token tree. This captured expression is then passed to `transform!($e)`, which attempts to match it against the pattern `$a:tt + $b:tt`.

However, because `$e` was already captured as an `:expr`, it cannot be pattern-matched as separate tokens anymore. The first arm `$a:tt + $b:tt` fails to match, so the second arm `$other:expr` matches instead, and the expression `2 + 3` is returned as-is, evaluating to `5`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably tweak the explanation here so that it's clear that this stuff only happens when capture is invoked via transform. In general it would be nice if the explanation highlighted the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants